#! /usr/bin/env python
# -*- coding: utf-8 -*-

from django.http import JsonResponse
from rest_framework import status
from rest_framework.decorators import api_view
from restapi.utils.retcode import *
from restapi.models import PocUserRank
from restapi.models import Importance
from restapi.models import Department
from restapi.models import Progress
from restapi.serializers import UserRankSerializer, ImportanceSerializer, DepartmentSerializer, ProgressSerializer

log = logger.get_logger(__name__)

@api_view(['GET'])
def get_user_rank(request):
    user_rank=PocUserRank.objects.all()
    return JsonResponse(retcode(UserRankSerializer(user_rank, many=True).data,"0000","success"),safe=True,status=status.HTTP_200_OK)

@api_view(['GET'])
def get_importance_param(request):
    importance_list = Importance.objects.all()
    return JsonResponse(retcode(ImportanceSerializer(importance_list, many=True).data, "0000", "Success"), safe=True,
                        status=status.HTTP_200_OK)


@api_view(['GET'])
def get_department_param(request):
    department_list = Department.objects.all()
    return JsonResponse(retcode(DepartmentSerializer(department_list, many=True).data, "0000", "Success"), safe=True,
                        status=status.HTTP_200_OK)


@api_view(['GET'])
def get_progress_param(request):
    log.info(request)
    Progress_list = Progress.objects.all()
    return JsonResponse(retcode(ProgressSerializer(Progress_list, many=True).data, "0000", "Success"), safe=True,
                        status=status.HTTP_200_OK)
